package nl.hva.web.mvcwebapp.models;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.*;
import org.hibernate.annotations.Type;

@Entity
@Table(name = "course")
public class Course implements Serializable {

        private int courseid;
    //@ManyToMany
    //private User user;
    private int coursecategory;
        private String coursetitle;
        private String coursedescription;
        private String coursepriority;
        private String coursepicture;
        private String headteacher;
    
        private Set<Chapter> chapters = new HashSet<Chapter>() {
    };
        private Set<News> news = new HashSet<News>() {
    };
    
    private Set<CourseUser> courseUser = new HashSet<CourseUser>(0);

   

    public Course() {
    }

    public Course(int courseid, int coursecategory, String coursetitle, String coursedescription, String coursepriority, String coursepicture) {
        this.courseid = courseid;
        this.coursecategory = coursecategory;
        this.coursetitle = coursetitle;
        this.coursedescription = coursedescription;
        this.coursepriority = coursepriority;
        this.coursepicture = coursepicture;
    }

    /**
     * @return the courseid
     */
    @Id
    @GeneratedValue
    @Column(name = "courseid")
    public int getCourseid() {
        return courseid;
    }

    /**
     * @param courseid the courseid to set
     */
    public void setCourseid(int courseid) {
        this.courseid = courseid;
    }

    /**
     * @return the coursecategory
     */
    @Column(name = "coursecategory")
    public int getCoursecategory() {
        return coursecategory;
    }

    /**
     * @param coursecategory the coursecategory to set
     */
    public void setCoursecategory(int coursecategory) {
        this.coursecategory = coursecategory;
    }

    /**
     * @return the coursetitle
     */
    @Column(name = "coursetitle")
    public String getCoursetitle() {
        return coursetitle;
    }

    /**
     * @param coursetitle the coursetitle to set
     */
    public void setCoursetitle(String coursetitle) {
        this.coursetitle = coursetitle;
    }

    /**
     * @return the coursedescription
     */
    @Column(name = "coursedescription")
    @Type(type="text")
    public String getCoursedescription() {
        return coursedescription;
    }

    /**
     * @param coursedescription the coursedescription to set
     */
    public void setCoursedescription(String coursedescription) {
        this.coursedescription = coursedescription;
    }

    /**
     * @return the coursepriority
     */
    @Column(name = "coursepriority")
    public String getCoursepriority() {
        return coursepriority;
    }

    /**
     * @param coursepriority the coursepriority to set
     */
    public void setCoursepriority(String coursepriority) {
        this.coursepriority = coursepriority;
    }

    /**
     * @return the coursepicture
     */
    @Column(name = "coursepicture")
    public String getCoursepicture() {
        return coursepicture;
    }

    /**
     * @param coursepicture the coursepicture to set
     */
    public void setCoursepicture(String coursepicture) {
        this.coursepicture = coursepicture;
    }

    /**
     * @return the chapters
     */
    @OneToMany
    public Set<Chapter> getChapters() {
        return chapters;
    }

    /**
     * @param chapters the chapters to set
     */
    public void setChapters(Set<Chapter> chapters) {
        this.chapters = chapters;
    }

    public void addChapter(Chapter chapter) {
        this.chapters.add(chapter);
    }

    @OneToMany
    public Set<News> getNews() {
        return news;
    }

    public void setNews(Set<News> news) {
        this.news = news;
    }
    

    /**
     * @return the headteacher
     */
    @Column(name = "headteacher")
    public String getHeadteacher() {
        return headteacher;
    }

    /**
     * @param headteacher the headteacher to set
     */
    public void setHeadteacher(String headteacher) {
        this.headteacher = headteacher;
    }

    /**
     * @return the courseUser
     */
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "pk.course", cascade = CascadeType.ALL)
    public Set<CourseUser> getCourseUser() {
        return courseUser;
    }

    /**
     * @param courseUser the courseUser to set
     */
    public void setCourseUser(Set<CourseUser> courseUser) {
        this.courseUser = courseUser;
    }
}
